<?php
namespace plugin\dianzishouxieqianming\model; 
use think\Model;
use think\facade\Db; 
class PluginDianzishouxieqianmingArticleCommentsLike extends Model
{
 
    
       public function is_exist($map)
     { 
       
         $finds = PluginDianzishouxieqianmingArticleCommentsLike::where($map)->find();
         if ($finds) {
           return true;
         } 
         
          return false;
     }
  
   
    //   public function paginate($map,$field,$order,$page)
    //  {
    // 
    //   if ($field) {
    //       $list = PluginDianzishouxieqianmingArticleCommentsLike::with('Category')->where($map)->order($order)->field($field)->paginate($page);
    //   } else { 
    //      $list = PluginDianzishouxieqianmingArticleCommentsLike::with('Category')
    //      ->alias('a')->join('plugin_dianzishouxieqianming_ad_jump b ','b.id= a.jump_id')
    //      ->field('a.*,b.jump_name,b.jump_ids')
    //      ->where($map)->order($order)->paginate($page);
    //   }

    //   $data['list']=$list;
    //   // $list = $list->all();
    //   return $data; 
    //  }
     
     
      public function adds($request)
     { 
        $request['create_time'] =    time();
 
     	$request['create_ip']   =    request()->ip();
     	
     	$map['uid'] = $request['uid'];
     	$map['comments_id'] = $request['comments_id'];
        $is_exist=	 $this->is_exist($map);
        
     	 if (!$is_exist) {
               unset($request['id']);
               $adds = new PluginDianzishouxieqianmingArticleCommentsLike;
               $adds->save($request); 
               return true;
     	 } 
     	 
        	  $this->dels($map);
        	  return false;
 
     }
 
 
 
       public function dels($map)
     {
  	  
  
       return  PluginDianzishouxieqianmingArticleCommentsLike::where($map)->delete();
   
        
     }
     //模型方法


}